//
//  RuKuRecordDetailVC.swift
//  物料商行
//
//  Created by HaoDong Hong on 2017/9/21.
//  Copyright © 2017年 HaoDong Hong. All rights reserved.
//

import UIKit

class RuKuRecordDetailVC: UIViewController, UITableViewDataSource, UITableViewDelegate {
    
    @IBOutlet weak var tableView: UITableView!
    var detail: [RuKuRecord.Detail]!

    override func viewDidLoad() {
        super.viewDidLoad()
        tableView.delegate = self
        tableView.dataSource = self
        tableView.contentInset = UIEdgeInsets(top: 44, left: 0, bottom: 0, right: 0)
        tableView.register(UINib(nibName: "RuKuRecordDetailCell", bundle: nil), forCellReuseIdentifier: "RuKuRecordDetailCell")
        
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "RuKuRecordDetailCell") as! RuKuRecordDetailCell
        if let url = URL(string: detail[indexPath.row].colorPicture) {
            cell.imgView.kf.setImage(with: url)
        }
        cell.numLabel.text = detail[indexPath.row].stock
        cell.noLabel.text = detail[indexPath.row].colorNo
        cell.colorLabel.text = detail[indexPath.row].materialColor
        cell.selectionStyle = .none
        return cell
    }
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 80
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return detail.count
    }

}
